import{Ot as e}from"./B603vO-13smUKN.js";import{$ as t,D as n,Ft as r,Ht as i,Nt as ee,On as a,Yt as o,Zn as s,_ as c,b as l,er as u,et as d,g as f,it as p,k as m,mt as h,o as te,qt as g,u as _,v,vn as y,wt as b,xt as x,y as S}from"./CIxmKYxc4tZcJF.js";import{S as C,t as w,w as T}from"./DWlEJV-j33On0I.js";import{l as ne,n as re,s as E,u as ie}from"./CrVzHk_r1oIxh7.js";import{a as ae,i as oe,n as D,o as O,s as k}from"./BE8xqUWO2F54bE.js";import{n as A,t as j}from"./DtKpc0mu2iK50y.js";var M={class:`_float_inner`},N=m({inheritAttrs:!1,__name:`oui-float`,props:t({reference:{},transition:{},placement:{},arrow:{type:Boolean},offset:{type:[Number,Object,Function]},padding:{},close:{type:Boolean},hover:{type:Boolean},delayEnter:{},delayLeave:{}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:t([`close`,`dblclick`],[`update:modelValue`]),setup(t,{emit:m}){let N=t,P=m,F=r(t,`modelValue`),I=y(),L=f(()=>I.value??N.reference),R=y(),z=y(),B=f(()=>N.placement??`top`),V=y(),{floatingStyles:H,middlewareData:U,placement:W}=A(L,R,{placement:B,whileElementsMounted:D,middleware:[ae(e(N.offset)?+N.offset:N.offset??0),oe(),O({padding:N.padding??16}),k({padding:N.padding??16,apply({availableHeight:e}){V.value=e}}),j({element:z})]}),G=f(()=>({...H.value,...V.value==null?{}:{"--oui-float-available-height":`${V.value}px`}}));i(F,e=>{e===!1&&P(`close`)});async function K(e){N.close&&F.value&&(e?.preventDefault(),e?.stopPropagation(),F.value=!1)}re(`Escape`,e=>K(e));let q;ne(`pointerup`,e=>{F.value&&R?.value?.contains?.(e.target)!==!0&&L?.value?.contains?.(e.target)!==!0&&(q=setTimeout(()=>F.value=!1,50))},{passive:!0}),p(()=>clearTimeout(q));let se=ee(),ce=f(()=>String(se.class||`oui-float`).split(/\s+/g)?.[0]);function J(e){F.value=!F.value,e.preventDefault()}let Y=y();i(Y,e=>{let t=e?.nextElementSibling;I.value=t,t?.addEventListener(`dblclick`,J),t?.addEventListener(`click`,J),t?.addEventListener(`contextmenu`,J),e&&!t&&console.error(`#click slot requires at least one element!`)});let X={delayLeave:N.delayLeave??250,delayEnter:N.delayEnter??0},Z=E(R,X),Q=E(L,X),{focused:$}=ie(R);return i(()=>[Z.value,Q.value,$.value],e=>{N.hover&&(F.value=!!(Z.value||Q.value||$.value))}),(e,r)=>(h(),l(te,null,[e.$slots.click?(h(),l(`div`,{key:0,ref_key:`slotReference`,ref:I,style:{display:`inline-block`},onClick:r[0]||=T(e=>F.value=!F.value,[`prevent`,`stop`]),onContextmenu:r[1]||=T(e=>F.value=!F.value,[`prevent`,`stop`])},[x(e.$slots,`click`,{active:F.value===!0})],544)):S(``,!0),e.$slots.trigger?(h(),v(b(e.$slots.trigger),{key:1,ref_key:`triggerSlot`,ref:Y,active:F.value===!0},null,8,[`active`])):S(``,!0),(h(),v(_,{to:`body`},[n(w,{name:t.transition??`${ce.value}-transition`},{default:g(()=>[o(c(`div`,d({ref_key:`floating`,ref:R,style:G.value,class:e.$attrs.class||`oui-float`},e.$attrs,{class:`_float`}),[o(c(`div`,{ref_key:`floatingArrow`,ref:z,class:s([`_float_arrow`,`_float_arrow_${a(W)}`]),style:u({position:`absolute`,left:a(U).arrow?.x==null?``:`${a(U).arrow.x}px`,top:a(U).arrow?.y==null?``:`${a(U).arrow.y}px`})},null,6),[[C,t.arrow??!1]]),c(`div`,M,[x(e.$slots,`default`)])],16),[[C,F.value]])]),_:3},8,[`name`])]))],64))}});export{N as t};